package com.example.myapplication001.slice.exercise;

import com.example.myapplication001.ResourceTable;
import com.example.myapplication001.slice.countdown.ExerciseThreeInRunAbilitySlice;
import com.example.myapplication001.slice.home_page.MainAbilitySlice;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Image;

//开始运动室内跑步

public class ExerciseInRunAbilitySlice extends AbilitySlice {
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_exercise_in_run);

        //添加五大运动类型按钮
        addButton();
        //添加返回图标和中间运动图标
        addImage();
    }

    private void addButton(){
        Button button_out_run=(Button) findComponentById(ResourceTable.Id_button_out_run);
        button_out_run.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                //进入室外跑步
                present(new ExerciseOutRunAbilitySlice(),new Intent());
            }
        });
        Button button_out_ride=(Button) findComponentById(ResourceTable.Id_button_out_ride);
        button_out_ride.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                //进入室外骑行
                present(new ExerciseOutRideAbilitySlice(),new Intent());
            }
        });
        Button button_out_foot=(Button) findComponentById(ResourceTable.Id_button_out_foot);
        button_out_foot.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                //进入室外步行
                present(new ExerciseOutFootAbilitySlice(),new Intent());
            }
        });
        Button button_in_foot=(Button) findComponentById(ResourceTable.Id_button_in_foot);
        button_in_foot.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                //进入室内步行
                present(new ExerciseInFootAbilitySlice(),new Intent());
            }
        });
    }

    private void addImage(){
        Image image_return =(Image) findComponentById(ResourceTable.Id_image_return);
        image_return.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                //进入MainAbilitySlice
                present(new MainAbilitySlice(),new Intent());
            }
        });

        Image image_start_in_run =(Image)findComponentById(ResourceTable.Id_image_start_in_run);
        image_start_in_run.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                //进入ExerciseThreeInRunSlice
                present(new ExerciseThreeInRunAbilitySlice(),new Intent());
            }
        });
    }


    @Override
    protected void onActive() {
        super.onActive();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }


}


